<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/layui/layui.js"></script>
    <link rel="stylesheet" href="../js/layui/css/layui.css"/>
</head>
<body>
<div class="layui-btn-container">
    <button class="layui-btn layui-btn-sm"  onclick="openAddDialog()">新增</button>
</div>
<table class="layui-hide" id="schoolTable" lay-filter="schoolFilter"></table>
</body>
<script>
    var table;
    var $;
    layui.use(['table'], function() {
        table = layui.table;
        $ = layui.jquery;
        table.render({
            id:'schoolTableId',
            elem: '#schoolTable',
            fit: true,
            url: '../web/findUserGongZuoJingLi', //数据接口
            cols: [
                [ //表头
                    {title: 'ID', checkbox: true},
                    {field: 'comname', title: '公司名称', align: 'center'},
                    {field: 'hangyetype', title: '行业类别', align: 'center'},
                    {field: 'workname', title: '职业名称', align: 'center'},
                    {field: 'zhiyetype', title: '职位类别', align: 'center'},
                    {field: 'workdate', title: '工作时间', align: 'center'},
                    {field: 'salary', title: '职位月薪', align: 'center'},
                    {field: 'pingjia', title: '自我评价', align: 'center'},
                    {field: 'caozuo',title: '操作', align: 'center', toolbar: '#toolbar'}
                    //, sort: true 这是排序
                ]
            ]
        });
        table.on('tool(schoolFilter)', function(obj){
            var data = obj.data;
            if(obj.event === 'del'){
                $.post("../web/delGongZuo",{id:data.id},function(data){
                    if(data){
                        table.reload("schoolTableId",{});
                    }else{
                        layer.alert("删除失败");
                    }
                })
            }
        })
    })

    //打开新增弹框
    function openAddDialog(){
        layer.open({
            type: 2,
            title:"新增教育经历",
            area: ['600px', '500px'],
            fixed:false,
            maxmin:true,
            content:'../page/toAddGongZuo',
            btn:['保存'],
            btn1: function(index,layero){
                //获取子页面
                var iframeWin= window[layero.find('iframe')[0]['name']];//得到iframe页的窗口对象,执行iframe页的方法
                iframeWin.saveGongZuo();
                table.reload("schoolTableId",{});
                layer.close(index);
            },
        });
    }

</script>
<script type="text/html" id="toolbar">
    <a class="layui-btn layui-btn-xs" lay-event="del">删除</a>
</script>
</html>


<!--
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>工作经历</title>
    <link rel="stylesheet" href="../js/layui/css/layui.css">
    <script src="../js/layui/layui.js"></script>
</head>
<body>
<div class="layui-btn-group demoTable">
    <button class="layui-btn" data-type="getCheckData" onclick="delMany()">批量删除</button>
    <button class="layui-btn"  onclick="openAddDialog()">新增</button>
</div>
<table class="layui-hide" id="userTable" lay-filter="userFilter"></table>
</body>
<script>
    var table;
    var $;
    layui.use(["table","form"],function(){
        table = layui.table;
        $ = layui.jquery;
        table.render({
            id:'userTableId',
            elem: '#userTable',
            url: '../web/findUserGongZuoJingLi', //数据接口
            cols: [
                [ //表头
                    {title: 'ID', checkbox: true},
                    {field: 'comname', title: '公司名称', align: 'center'},
                    {field: 'hangyetype', title: '行业类别', align: 'center'},
                    {field: 'workname', title: '职业名称', align: 'center'},
                    {field: 'zhiyetype', title: '职位类别', align: 'center'},
                    {field: 'workdate', title: '工作时间', align: 'center'},
                    {field: 'salary', title: '职位月薪', align: 'center'},
                    {field: 'pingjia', title: '自我评价', align: 'center'},
                    {field: 'caozuo',title: '操作', align: 'center', toolbar: '#toolbar'}
                    //, sort: true 这是排序
                ]
            ]
        })
        table.on('tool(userFilter)',function(obj){
            var data = obj.data;
            if (obj.event == 'edit'){
                openEditDialog(data.id);
                layer.msg('编辑数据'+data.id)
            }
            if(obj.event === 'del'){//删除商品
                $.post("../web/delManyProduct",{ids:data.id},function(data){
                    if(data){
                        table.reload("userTableId",{});
                    }else{
                        layer.alert("删除失败");
                    }
                })
            }
        })
    })
    /**
     * 修改：回显
     * */
    function openEditDialog(id) {
        layer.open({
            type:2,
            title:'编辑商品',
            area:['700px','500px'],
            fixed:false, //是否固定
            maxmin:true,    //是否支持最大 最小化
            content:'../page/toEditProduct',
            btn:['保存'],
            success:function(layero,index){
                $.post('../web/findProductInfo',{id:id},function(data){
                    var iframeWin= window[layero.find('iframe')[0]['name']];//得到iframe页的窗口对象,执行iframe页的方法
                    iframeWin.loadForm(data);
                })
            },
            btn1:function(index,layero){
                //获取子页面
                var iframeWin= window[layero.find('iframe')[0]['name']];//得到iframe页的窗口对象,执行iframe页的方法
                iframeWin.saveProduct();
                table.reload("productTableId",{});
                layer.close(index);
            }
        })

    }
    /**
     * 新增内容
     * */
    function openAddDialog(){
        layer.open({
            type:2,
            title:'新增商品',
            area:['700px','500px'],
            fixed:false, //是否固定
            maxmin:true,    //是否支持最大 最小化
            content:'../page/toAddProduct',
            btn:['保存'],
            btn1: function(index,layero){
                //获取子页面
                var iframeWin= window[layero.find('iframe')[0]['name']];//得到iframe页的窗口对象,执行iframe页的方法
                iframeWin.saveProduct();
                table.reload("productTableId",{});
                layer.close(index);
            },
        });
    }

    /**
     * 批量删除
     * */
    function delMany(){
        var checkStatus = table.checkStatus("productTableId");
        var data = checkStatus.data;
        var ids = "";
        for(var i = 0 ; i < data.length ; i++ ){
            ids += ids == "" ? data[i].id : "," + data[i].id;
        }
        //layer.alert(ids)
        $.post("../web/delManyProduct",{ids:ids},function(data){
            if(data){
                layer.close();
                table.reload("productTableId",{});
            }else{
                layer.alert("删除失败");
            }
        })
    }


</script>
<script type="text/html" id="toolbar">

    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>

</html>-->
